package cn.caplike.demo.repository.design.pattern.builder.entity;

public class Student {
    /** Required */ private String name;
    /** Optional */ private int age;
    private String title;

    public static Builder of(String name) {
        return new Builder(name);
    }

    public static class Builder {
        private final Student artifact;

        public Builder(String name) {
            artifact = new Student();
            artifact.name = name;
        }

        public Builder age(int age) {
            artifact.age = age;
            return this;
        }

        public Builder title(String s) {
            artifact.title = s;
            return this;
        }

        public Student build() {
            return artifact;
        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", title='" + title + '\'' +
                '}';
    }
}
